'Linker: LINK DODIR,,,PRO7; -- uses crescent library
'WHY SOURCE??? WHY NOT??? There's nothing magic about writing a program;
'the magic is in the elegance of the design. Most hide their lack of elegance.
'I'm at least admitting to and showing everyone my lack...
'And, if occasionally, I find elegance--I want everybody to know about it. <g>
'This program has no subprogram or functions. The size of the program and
'it's limited functionality dictate that's a more than adequate use of
'structure and gosub is faster and a lot cleaner when the scope of the
'program is so limited.
'The program will process all the files in a directory using AC150a or such
'to convert the file from a zip to an arj or whatever
'the program expects to find GEN\DLPATH but that can be revised by setting
'the environment variable PCBPATH before activating this program.
'PCBLOG environment variable will send the output to a file rather than the
'screen if you wish to be able to review the results after an event.
DEFINT A-Z
' remarks like '* are for KCC conditional operation--another TOOLKIT program
' it allows switching from debugging to production code automatically
' KCC is available as a program or as source from TOOLKIT BBS 219-696-3415
' you don't have PDS, you'll need to make a number of changes at the END #'s
'These routines are part of the PDQ and/or QuickPak libraries from Crescent
'most functionality could be replace using HANLIN's shareware libraries
'or DIR$ function and later use program that changes/checks filesizes that's
'found in my PCBMAINT.ZIP collection
'all routines from CRESCENT LIB -- substitue from HANLIN LIB if you don't have
DECLARE FUNCTION Exist% (x$) 'check for existance of file
DECLARE FUNCTION FileSize& (x$) 'get the new size of the file being changed
'my goodness, code... you thought we'd never get there, I bet!
IF COMMAND$ = "" THEN
PRINT "DODIR [Drv:Path]DIR##"
PRINT "Where: The paramater passed points to a valid PCB DIR"
PRINT "SET: The Following may be set in the environment for use by Program."
PRINT " PCBPATH=[BLANK] your pcb master directory--default running from that dir"
PRINT " PCBARC=.ZIP or whatever your extension converting from"
PRINT " ACCMD=ACNV /J /C -- the parameters you want to pass"
PRINT " PCBNEWARC=.ARJ or the extension for the file you're converting from"
PRINT " PCBLOG=CONS: Device:/Filename you want to send program output"
PRINT " BYPASS=01-31-91 bypass group of files with this in the line"
PRINT " TESTING=-1 pretend you're converting to look shelled command and cycling"
PRINT "Defaults shown. Program finds the file in the GEN\DLPATH.LST and calls the"
PRINT "conversion program. After conversion it changes the file extension and "
PRINT "adjusts the filesize to reflect the info. Be sure to clear ENV afterward."
END 99 'make sure just about any error noting will hit in batch
END IF
'if he got this far, he may have browsed the docs
HomeDir$ = CURDIR$ 'save it so we can get back when we are done
'this notice must remain with this and all dirivative works
x$ = "COPYRIGHT 1991 by Ken Prevo--ALL RIGHTS RESERVED"
PRINT x$
Testing% = VAL(ENVIRON$("TESTING"))
PCBPath$ = ENVIRON$("PCBPATH")
IF PCBPath$ = "" THEN PCBPath$ = "GEN\DLPATH.LST" '*
'*IF PCBPath$ = "" THEN PCBPath$ = "G:\bbs\GEN\DLPATH.LST" 'testing
PCBArchiver$ = ENVIRON$("PCBARC")
IF PCBArchiver$ = "" THEN PCBArchiver$ = ".ZIP"
ACCmd$ = ENVIRON$("ACCMD")
IF ACCmd$ = "" THEN ACCmd$ = "ACCMD /J /C"
PCBNewArc$ = ENVIRON$("PCBNEWARC")
IF PCBNewArc$ = "" THEN PCBNewArc$ = ".ARJ"
Bypass$ = ENVIRON$("BYPASS")
IF Bypass$ = "" THEN Bypass$ = "01-31-91"'my cd files are indicated so...
LogF$ = ENVIRON$("PCBLOG")
IF LogF$ = "" THEN LogF$ = "CONS:"
IF PCBLog$ <> "CONS:" THEN ToScreen% = -1:
IF NOT Exist%(PCBPath$) THEN
PRINT PCBPath$; " not found -- set this value as environment variable PCBPATH"
END 1
ELSE
PRINT "Download list: "; PCBPath$
END IF
IF LogF$ <> "CONS:" AND NOT Exist%(LogF$) THEN
PRINT LogF$; "--error--file not found--set environment variable PCBLOG$)"
END 1
ELSE
PRINT "Logging to "; LogF$
END IF
OPEN PCBPath$ FOR INPUT AS 1
subdir% = 0
DO WHILE NOT EOF(1)
LINE INPUT #1, x$
IF LEFT$(x$, 1) <> "@" THEN subdir% = subdir% + 1
LOOP
CLOSE 1
DIM SubDirs$(subdir%)
subdir% = subdir% - 1 'base 0 but allow extra for throwaway items$
OPEN PCBPath$ FOR INPUT AS 1
i% = 0
DO WHILE NOT EOF(1)
LINE INPUT #1, SubDirs$(i%)
IF LEFT$(SubDirs$(i%), 1) <> "@" THEN
'subdirs$(i%) = RTRIM$(subdirs$(i%))'in case some putz did an ASCII edit and added spaces--who be so dumb as to do that you ask??? -- Besides you and me!!!
PRINT "|"; SubDirs$(i%); "|"
i% = i% + 1
ELSE
SubDirs$(i%) = ""
END IF
LOOP
CLOSE 1
OPEN LogF$ FOR OUTPUT AS 3
CmdStr$ = UCASE$(COMMAND$) + " "
PRINT "Command Line: "; COMMAND$
CLPtr% = 1'
'If he got this far, he read and understood the docs--oh, happy day!
'(I hope he didn't forget what to put in the command line...)
DO 'unadvertised feature, I don't use so didn't try/document it
'process multiple files in single program iteration--caveat emptor
CLPtr2% = INSTR(CLPtr%, CmdStr$, " ")
IF CLPtr2% = 0 THEN CLPtr2% = LEN(CmdStr$)
IF CLPtr% = CLPtr2% THEN EXIT DO
CurrentDir$ = RTRIM$(MID$(CmdStr$, CLPtr%, CLPtr2% - CLPtr% + 1)) 'parse way through command line items
CLPtr% = CLPtr2%
IF LEN(CurrentDir$) THEN 'done parsing
IF NOT Exist%(CurrentDir$) THEN
PRINT #3, "Missing Directory: "; CurrentDir$
END 2
ELSE
PRINT "Dir: "; CurrentDir$
END IF
p% = INSTR(CurrentDir$, ".")
IF p% = 0 THEN
CurrentDir$ = CurrentDir$ + "."
p% = LEN(CurrentDir$)
END IF
BakFile$ = CurrentDir$ + "BAK"
IF Exist%(BakFile$) THEN KILL BakFile$
NAME CurrentDir$ AS BakFile$
OPEN BakFile$ FOR INPUT AS 1
OPEN CurrentDir$ FOR OUTPUT AS 2
DO WHILE NOT EOF(1) '!!!!!main file processing loop!!!!!
LINE INPUT #1, MasterStr$
IF LEFT$(MasterStr$, 1) > " " THEN 'process as a file
GOSUB ProcessItem
ELSE 'pass it through
PRINT #2, MasterStr$
END IF
LOOP
CLOSE 1, 2
END IF
LOOP
CHDIR HomeDir$
PRINT #3, "Original:"; OldTotFS&
PRINT #3, "New: "; NewTotFS&
PRINT #3, "Savings: "; OldTotFS& - NewTotFS&
IF FileSize&(PCBPath$) <> FileSize&(CurrentDir$) THEN PRINT #3, "New DIR doesn't match old dir size--check it out"
CLOSE 3
END 0 'normal exit--processing complete
ProcessItem:
IF NOT ToScreen% THEN
IF ToLeft% THEN
PRINT CHR$(8); 'destructive backspace
Ypos% = Ypos% - 1
IF Ypos% = 0 THEN
ToLeft% = 0
END IF
ELSE 'print to right
PRINT ".";
Ypos% = Ypos% + 1
IF Ypos% > 78 THEN
ToLeft% = -1
END IF
END IF
END IF
Test$ = RTRIM$(LEFT$(MasterStr$, 13))
TestPtr% = INSTR(Test$, PCBArchiver$) AND INSTR(MasterStr$, Bypass$) = 0
IF TestPtr% > 0 THEN 'it is the archive fmt we want to convert
FOR i% = 0 TO subdir%
x$ = SubDirs$(i%) + Test$
IF Exist%(x$) THEN 'convert the file
FS& = FileSize&(x$)
OldTotFS& = OldTotFS& + FS&
PRINT #3, x$; FS&; " - ";
'subdir always has drive in left 2 characters and needs to have the trailing \ removed for chdir
xx$ = LEFT$(SubDirs$(i%), 2)
CHDRIVE xx$
xx$ = LEFT$(SubDirs$(i%), LEN(SubDirs$(i%)) - 1)
CHDIR xx$
IF Testing% THEN
PRINT ACCmd$; " "; x$;
IF Exist%(Test$) THEN PRINT " -- found for processing" ELSE PRINT " -- Missing FIle"